﻿using ConfExpert.Forms.Base;
using DevTeam;
using System;
using System.Data;

namespace ConfExpert.Forms.Ithalat
{
    public partial class ExecSummary : XForm
    {
        public ExecSummary()
        {
            InitializeComponent();
        }

        private void ExecSummary_Load(object sender, EventArgs e)
        {
            gridView1.Init("GetMasrafByHesapPlani");

            foreach (DataColumn col in gridView1.DataTable().Columns)
            {
                string hp = col.ColumnName;

                if (hp.StartsWith("20"))
                {
                    gridView1.FormatAsNumber(1, hp);
                    gridView1.AddSummary(hp);
                    //gridView1.SetCaptions(hp + ":" + r["Abbr"].ToStr());
                    //gridView1.Columns[hp].ToolTip = r["Aciklama"].ToStr();  // r["HesapKodu"].ToStr() + ". " + r["Name"].ToStr();
                }

            }

            gridView1.MakeReadOnly();
            gridView1.FormatAsNumber(1, "Toplam");
            gridView1.AddSummary("Toplam");
            gridView1.BestFitColumns();

            gridView1.DoubleClick += gridView1_DoubleClick;
        }

        void gridView1_DoubleClick(object sender, EventArgs e)
        {
            int HesapPlaniId = gridView1.GetFocusedDataRow()["HesapPlaniId"].ToInt();
            string col = gridView1.FocusedColumn.FieldName;

            using (MasrafExecDetay md = new MasrafExecDetay(HesapPlaniId, col))
                md.ShowDialog();
        }
    }
}
